#include "web/SockAddrIn.h"

using namespace Web;

const char *SockAddrIn::GetIP() const
{
    return inet_ntoa(m_AddrIn.sin_addr);
}

unsigned int SockAddrIn::GetPort() const
{
    return m_AddrIn.sin_port;
}

unsigned int Web::SockAddrIn::GetFamily() const
{
    return m_AddrIn.sin_family;
}

void SockAddrIn::SetFamilyHostPort(int family, const char* host, unsigned int port)
{
    SetFamily(family);
    SetHost(host);
    SetPort(port);
}

        void SockAddrIn::SetFamilyAddrPort(int family, int addr, int  port)
        {
    SetFamily(family);
    SetAddr(addr);
    SetPort(port);
}


void SockAddrIn::SetAddr(const unsigned int &addr)
{
    this->m_AddrIn.sin_addr.s_addr = htonl(addr);
}

void SockAddrIn::SetHost(const char *host)
{
    m_AddrIn.sin_addr.s_addr = inet_addr(host);
}

void SockAddrIn::SetPort(const unsigned int &port)
{
    m_AddrIn.sin_port = htons(port);
}

void SockAddrIn::SetFamily(const unsigned int &family)
{
    m_AddrIn.sin_family = family;
}

struct sockaddr *SockAddrIn::GetSockAddr() const
{
    return (struct sockaddr *)&this->m_AddrIn;
}
